﻿@inherits TreeTableBase<DeptDto, int, DeptEdit, EditInput<int?>, EditOutput<int>>
@page "/system_manager/dept"
@using Gardener.Application.Dtos
<div>
    <PageContainer Title="">
        <Breadcrumb>
            <Breadcrumb>
                <BreadcrumbItem>用户权限</BreadcrumbItem>
                <BreadcrumbItem>部门管理</BreadcrumbItem>
            </Breadcrumb>
        </Breadcrumb>
        <ChildContent>
            <Table @ref="_table"
                   TItem="DeptDto"
                   DataSource="@_dtos"
                   OnChange="@onChange"
                   TreeChildren="item=>item.Children"
                   @bind-SelectedRows="_selectedRows"
                   Loading="@_tableIsLoading"
                   HidePagination="true"
                   IndentSize="25"
                   Context="model">
                <TitleTemplate>
                    <Row>
                        <AntDesign.Col Span="8">
                            <ResourceAuthorize ResourceKey="system_manager_dept_delete_selected">
                                <Button Type="@ButtonType.Primary" Icon="delete" Danger OnClick="OnDeletesClick">
                                    删除选中
                                </Button>
                            </ResourceAuthorize>
                        </AntDesign.Col>
                        <AntDesign.Col Span="16" Style="text-align:right">
                            <Space>
                                <ResourceAuthorize ResourceKey="system_manager_dept_add">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="plus" OnClick="OnAddClick">
                                            添加
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                                <ResourceAuthorize ResourceKey="system_manager_dept_refresh">
                                    <SpaceItem>
                                        <Button Type="@ButtonType.Primary" Icon="reload" OnClick="OnReLoadTable">
                                            刷新
                                        </Button>
                                    </SpaceItem>
                                </ResourceAuthorize>
                            </Space>
                        </AntDesign.Col>
                    </Row>

                </TitleTemplate>
                <RowTemplate>
                    <Selection CheckStrictly Width="5%" />
                    <Column @bind-Field="@model.Name" Width="25%" />
                    <Column @bind-Field="@model.Contacts" Width="10%" />
                    <Column @bind-Field="@model.Tel" Width="10%" />
                    <Column @bind-Field="@model.Order" Width="10%" />
                    <Column @bind-Field="@model.Remark" Width="10%" />
                    <Column @bind-Field="@model.IsLocked" Width="10%">
                        <ResourceAuthorize ResourceKey="system_manager_dept_lock">
                            <Authorized>
                                <Switch @bind-Value="@model.IsLocked" OnChange="e=>OnChangeIsLocked(model,e)"></Switch>
                            </Authorized>
                            <NotAuthorized>
                                <TagYesNo Yes="model.IsLocked"></TagYesNo>
                            </NotAuthorized>
                        </ResourceAuthorize>
                    </Column>
                    <Column @bind-Field="@model.CreatedTime" Format="@ClientConstant.DateTimeFormat" Sortable Width="10%" />
                    <ActionColumn Width="10%">
                        <Space>
                            <ResourceAuthorize ResourceKey="system_manager_dept_add_children">
                                <SpaceItem>
                                    <Tooltip Title="@("添加子项")" ArrowPointAtCenter="true">
                                        <Button Icon="subnode" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnAddChildrenClick(model)"></Button>
                                    </Tooltip>
                                </SpaceItem>
                            </ResourceAuthorize>
                            <ResourceAuthorize ResourceKey="system_manager_dept_edit">
                                <SpaceItem>
                                    <Tooltip Title="@("编辑")" ArrowPointAtCenter="true">
                                        <Button Icon="edit" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnEditClick(model)"></Button>
                                    </Tooltip>
                                </SpaceItem>
                            </ResourceAuthorize>
                            @*<ResourceAuthorize ResourceKey="system_manager_dept_set_resource">
                    <SpaceItem>
                        <Tooltip Title="@("分配资源")" ArrowPointAtCenter="true">
                            <Button Icon="security-scan" Type="@ButtonType.Primary" Size="@ClientConstant.OperationButtonSize" OnClick="()=>OnEditRoleResourceClick(model.Id)"></Button>
                        </Tooltip>
                    </SpaceItem>
                </ResourceAuthorize>*@
                            <ResourceAuthorize ResourceKey="system_manager_dept_delete">
                                <SpaceItem>
                                    <Tooltip Title="@("删除(包含子节点)")" ArrowPointAtCenter="true">
                                        <Button Icon="delete" Type="@ButtonType.Primary" Danger OnClick="()=>OnDeleteClick(model)"></Button>
                                    </Tooltip>
                                </SpaceItem>
                            </ResourceAuthorize>
                        </Space>
                    </ActionColumn>
                </RowTemplate>
            </Table>
        </ChildContent>
    </PageContainer>
</div>